package zhieasy.cn.xpu_helper.controller.found;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhieasy.cn.common.vo.ResultVO;
import zhieasy.cn.model.found.Notice;
import zhieasy.cn.service.found.NoticeService;

/**
 * @author wangzeya
 * @create 2020-08-02 21:33:00
 */
@RestController
@RequestMapping("/found")
@Api(tags = "失物招领模块，公告处理接口")
@ApiImplicitParams({
        @ApiImplicitParam(name="notice",value ="失物招领",required =true,paramType="form",dataType="String"),
        @ApiImplicitParam(name="pageNum",value ="当前页码",required =true,paramType="form",dataType="int"),
        @ApiImplicitParam(name="pageSize",value ="页面大小",required =true,paramType="form",dataType="int")
})
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    /**
     * 发布公告
     *
     * @param notice
     * @return ResultVO
     */
    @ApiOperation(value = "发布公告", notes = "发布公告")
    @PostMapping(value = "/notice", produces = "application/json;charset=UTF-8")
    public ResultVO createNotice(@ApiParam("公告对象") @RequestBody Notice notice) {
        notice.setNoticeCreateTime(System.currentTimeMillis());
        return noticeService.createNotice(notice);
    }

    /**
     * 列表查看公告
     * @return ResultVO<IPage<Notice>>
     */
    @ApiOperation(value = "列表查看公告", notes = "列表查看公告")
    @GetMapping(value = "/notice", produces = "application/json;charset=UTF-8")
    public ResultVO<IPage<Notice>> findNoticeList(@ApiParam("页数")@RequestParam("pageIndex")int pageIndex,
                                                  @ApiParam("每页要多少数据")@RequestParam("pageSize")int pageSize) {
        return noticeService.findNoticeList(pageIndex, pageSize);
    }


}
